package com.jspgou.cms.manager.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jspgou.cms.dao.OrderItemDao;
import com.jspgou.cms.entity.OrderItem;
import com.jspgou.cms.manager.OrderItemMng;
import com.jspgou.common.page.Pagination;

@Service
@Transactional
public class OrderItemMngImpl implements OrderItemMng{

	public List<Object[]> profitTop(Long ctgid,Long typeid,Integer pageNo,Integer pageSize) {
		return dao.profitTop(ctgid,typeid,pageNo,pageSize);
	}

	public Integer totalCount(Long ctgid,Long typeid) {
		return dao.totalCount(ctgid,typeid);
	}
	
	@SuppressWarnings("unchecked")
	public Pagination getPageByMember(Long webId,int status,Long memberId,int pageNo,int pageSize){
		Object[]  o = dao.getPageByMember(webId, status, memberId, pageNo, pageSize);
		List<OrderItem> list =(List<OrderItem>)o[0];
		Integer total = (Integer)o[1];
		Pagination p = new Pagination(pageNo,pageSize,total,list);
		return p;
	}

	public Pagination getPage(Long webId,Long productId,Long paymentId,Long shippingId,Long storeId,
			String code,Date startTime,Date endTime,Integer status,Integer paymentStatus,Integer shippingStatus,int pageNo,int pageSize){
		Pagination  p = dao.getPage(webId,productId,paymentId,shippingId,storeId,
				code,startTime,endTime, status,paymentStatus,shippingStatus, pageNo, pageSize);
		return p;
	}
	
	public List<OrderItem> getList(Long webId,Long productId,Long paymentId,Long shippingId,Long storeId,
			String code,Date startTime,Date endTime,Integer status){
		List<OrderItem>  list = dao.getList(webId,productId,paymentId,shippingId,
				code,startTime,endTime, status);
		return list;
	}
	
	public List<Object[]> getOrderItem(){
		List<Object[]> orderItemList=dao.getOrderItem();
		return orderItemList;
	}
	
	public OrderItem findById(Long id){
		return dao.findById(id);
	}

	public OrderItem findByMember(Long memberId,Long productId){
		return dao.findByMember(memberId, productId);
	}
	
	public Pagination getOrderItem(Integer pageNo,Integer pageSize,Long productId){
		List<OrderItem> list = dao.getOrderItemList(productId, pageNo, pageSize);
		 List<OrderItem> list1= dao.getOrderItem(productId);
		 int total = list1.size();
		Pagination p = new Pagination(pageNo,pageSize,total,list);
		return p;
	}
	
	@Autowired
	private OrderItemDao dao;
	
}

